package org.juc.stream;

import java.util.function.Consumer;

public class ConsumerDemo {
    public static void main(String[] args) {
        // 匿名接口调用接口
        anonymousInterface();

       //  使用JDK内置的消费型接口实现
        ConsumeInterface();
    }

    /**
     * 消费型接口
     */
    private static void ConsumeInterface() {
        Consumer<String> consumer = new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        consumer.accept("EDF");
    }

    /**
     * 匿名的接口
     */
    private static void anonymousInterface() {
        TestConsumer consumer = new TestConsumer() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        consumer.accept("EDF");
    }
}


/**
 * 测试消费者
 *
 * @author Admin
 * @date 2021/11/30
 */
interface TestConsumer{
    void accept(String s);
}
